//
//  ZCBaseViewController.m
//  gamebox_qpp
//
//  Created by 赵隆杰 on 2021/12/10.
//

#import "ZCBaseViewController.h"

@interface ZCBaseViewController ()

@end

@implementation ZCBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = kBgColor;
    
    [self setupUI];
    [self setupNavi];
    
}

- (void)setupUI {
    self.tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
    self.tableView.estimatedRowHeight = 0;
    self.tableView.estimatedSectionHeaderHeight = 0;
    self.tableView.estimatedSectionFooterHeight = 0;

    self.tableView.backgroundColor = kViewBgColor;
    self.tableView.scrollsToTop = YES;
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    
    self.tableView.emptyDataSetSource = self;
    self.tableView.emptyDataSetDelegate = self;
    
    self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SL_WINDOW_WIDTH, CGFLOAT_MIN)];
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SL_WINDOW_WIDTH, CGFLOAT_MIN)];
    
}
- (void)setupNavi {
    UIView *naviView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SL_WINDOW_WIDTH, UIDevice.vg_navigationFullHeight)];
    naviView.backgroundColor = [[UIColor whiteColor] colorWithAlphaComponent:1.0];
    [self.view addSubview:naviView];
    self.naviView = naviView;
    
    UIButton *backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, UIDevice.vg_statusBarHeight, UIDevice.vg_navigationBarHeight, UIDevice.vg_navigationBarHeight)];
    backBtn.contentMode = UIViewContentModeCenter;
    [backBtn setImage:[UIImage imageNamed:@"ic_detail_toolbar_back_black"] forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(backBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.naviView addSubview:backBtn];
    self.backBtn = backBtn;
    
    UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(SL_WINDOW_WIDTH - UIDevice.vg_navigationBarHeight, UIDevice.vg_statusBarHeight, UIDevice.vg_navigationBarHeight, UIDevice.vg_navigationBarHeight)];
    rightBtn.contentMode = UIViewContentModeCenter;
    [rightBtn setTitleColor:kColor333333 forState:UIControlStateNormal];
    [rightBtn addTarget:self action:@selector(rightBtnClick) forControlEvents:UIControlEventTouchUpInside];
    [self.naviView addSubview:rightBtn];
    self.rightBtn = rightBtn;
    
    UILabel *centerTitle = [[UILabel alloc] initWithFrame:CGRectMake(backBtn.right, UIDevice.vg_statusBarHeight, rightBtn.left - backBtn.right, UIDevice.vg_navigationBarHeight)];
    centerTitle.center = CGPointMake(self.naviView.centerX, rightBtn.centerY);
    centerTitle.font = [UIFont boldSystemFontOfSize:18];
    centerTitle.textColor = kColor333333;
    centerTitle.textAlignment = NSTextAlignmentCenter;
    [self.naviView addSubview:centerTitle];
    self.centerTitle = centerTitle;
    
    UILabel *bottomLine = [[UILabel alloc] initWithFrame:CGRectMake(0, naviView.bottom - 1, naviView.width, 1)];
    bottomLine.backgroundColor = kLineColor;
    [self.naviView addSubview:bottomLine];
    self.bottomLine = bottomLine;
    
    ZCBaseViewController *first = (ZCBaseViewController *)self.navigationController.viewControllers.firstObject;
    if ([first isEqual:self]) {
        self.backBtn.hidden = YES;
        self.rightBtn.hidden = YES;
    } else {
        self.backBtn.hidden = NO;
        self.rightBtn.hidden = NO;
    }

}




# pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [[UITableViewCell alloc] init];
}

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section {
    view.tintColor = [UIColor clearColor];
}

- (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section {
    view.tintColor = [UIColor clearColor];
}

#pragma mark - DZNEmptyDataSetSource
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
    NSString *title = @"空空如也";
    NSDictionary *attributes = @{
                                 NSFontAttributeName:[UIFont systemFontOfSize:14],
                                 NSForegroundColorAttributeName:kColor888888
                                 };
    return [[NSAttributedString alloc] initWithString:title attributes:attributes];
}
- (UIImage *)imageForEmptyDataSet:(UIScrollView *)scrollView{
    return [UIImage imageNamed_common:@"nodata"];
}
- (BOOL)emptyDataSetShouldAllowScroll:(UIScrollView *)scrollView
{
    return YES;
}
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView{
    return -100;
}
- (void)emptyDataSetWillAppear:(UIScrollView *)scrollView {
    [self.tableView setContentOffset:CGPointMake(0, -self.tableView.contentInset.top)];
}

- (void)refreshAfterLogin {}

- (void)backBtnClick
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)rightBtnClick
{
    
}


@end
